<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>在线投票系统</title>
<link type="image/x-icon" href="images/yc.png" rel="shortcut icon"/>
<link type="text/css" rel="stylesheet" href="css/style.css" />

</head>
<body>
<div id="header" class="wrap">
	<img src="images/logo.gif" />
</div>
<div id="navbar" class="wrap">
	<div class="search">
	</div>
</div>
<div id="register" class="box">
	<h2>新用户注册</h2>
	<div class="content">
	   <form method="post" action="#" onsubmit="return false">
			<dl>
				<dt>用户名：</dt>
				<dd><input type="text" class="input-text" name="userName" v-model="uf.uname"/></dd>
				<dt>密码：</dt>
				<dd><input type="password" class="input-text" name="password" v-model="uf.pwd"/></dd>
				<dt>确认密码：</dt>
				<dd><input type="password" class="input-text" name="confirmPassword" v-model="apwd"/></dd>
				<dt></dt>
				<dd><input type="submit" class="input-button" name="submit" @click="reg" value=""/></dd>
			</dl>
		</form>
		<div class="error"></div>
		<div class="error"></div>
	</div>
</div>
<div id="footer" class="wrap">
	源辰信息 &copy; 版权所有
</div>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/axios.js"></script>
<script type="text/javascript" src="js/qs.js"></script>
<script type="text/javascript">
	let app = new Vue({
		el: "#register",
		data :{
			uf: {
				uname:"",
				pwd:""
			},
			apwd:""
		},
		methods:{
			reg:function(){
				if(this.uf.uname == "" || this.uf.pwd == "" || this.uf.pwd != this.apwd){
					return;
				}
				axios.post("user/reg",qs.stringify(this.uf)).then(rt =>{
					if(rt.status == 200 && rt.data.code){
						location.href="reg_success.html";
						return;
					}
					alert("注册失败，请稍后重试。。。");
				})
			}
		}
	})
</script> 
</body>
</html>
